{extend name="base"}
{block name="main"}
<h3>添加管理员</h3>
<form action="{:url('admin/admin/add')}" id="addAdmin" method="post">
    <table width="70%" border="1" cellpadding="5" cellspacing="0" bgcolor="#cccccc">
        <tr>
            <td align="right">管理员名称</td>
            <td><input type="text" name="username" placeholder="请输入管理员名称"/></td>
        </tr>
        <tr>
            <td align="right">管理员密码</td>
            <td><input type="password" name="password" /></td>
        </tr>
        <tr>
            <td align="right">管理员邮箱</td>
            <td><input type="text" name="email" placeholder="请输入管理员邮箱"/></td>
        </tr>
        <tr>
            <td colspan="2"><button id="submit" type="button" class="submit">添加管理员</button></td>
            <td colspan="2"><input type="submit" name="submit" value="tianjia "/></button></td>
        </tr>
    </table>
</form>

{load href='__PUBLIC__/static/js/jquery-3.1.1.min.js'}
<script type="text/javascript">
    $('.submit').click(function () {
        $.ajax({
            cache: true,
            type: "POST",
            url : '{:url('admin/admin/add')}',
            data: $('#addAdmin').serialize(),
            async: false,
            success: function(data) {
                if (data.code) {
                    alert(data.msg);
                    setTimeout(function () {
                        location.href = data.url;
                    }, 1000);
                } else {
                alert(data.msg);
                }
            },
            error: function(request) {
                alert("页面错误");
            }
        });
    });
</script>
{/block}